import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
/* Layout */
import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path*',
        component: () => import('@/views/redirect/index')
      }
    ]
  }
]

export const asyncRoutes = [{
  path: '/singleProve',
  component: Layout,
  meta: { title: '菜单' },
  children: [
    {
      path: 'enter',
      name: 'Enter',
      component: () => import('@/views/singleProve/enter'),
      meta: { title: '菜单一', noCache: false }
    },
    {
      path: 'into',
      name: 'Into',
      component: () => import('@/views/singleProve/into'),
      meta: { title: '菜单二', noCache: false }
    }
  ]
}]

const createRouter = () => new Router({
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
